import { BaseWindow } from "../../../../component/window/BaseWindow";
import { Language } from "../../../../../extend/language/Language";
import { PulseSharedObject } from "../../player/PulseSharedObject";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ObjCreate } from "../../common/ObjCreate";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { GCheckBox } from "../../../../../com/mui/controls/GCheckBox";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class RefreshConfirmWindow
    
    export  class RefreshConfirmWindow extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(300, 160);
            title = Language.getString(54164);
            return;
        }

        /* internal  */onCheckBoxChange(arg1: Object /* flash.events.Event */): void
        {
            if (this._checkBox.selected == true) 
            {
                PulseSharedObject.save(RefreshConfirmWindow.confirmKey, true);
            }
            return;
        }

        public updateData(arg1: int, arg2: int, arg3: int, arg4: Function=null): void
        {
            var loc1=GameDefConfig.instance.getEPrictUnitName(arg1);
            var loc2=arg3 > 1 ? Language.getString(54165) : "";
            var loc3=HTMLUtil.addColor(arg2 + loc1, GlobalStyle.color6);
            this._infoTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(54166, loc3, loc2), "#ffffff");
            RefreshConfirmWindow.clickHandler = arg4;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._middleBg = ObjCreate.createBg(17, 40, 265, 110, this);
            this._infoTxt = new Object /* flash.text.TextField */();
            this._infoTxt.defaultTextFormat = new GTextFormat(FontUtil.songtiName, 12, 16777215, null, null, null, null, null, flash.text.TextFormatAlign.LEFT, null, null, null, 8);
            this._infoTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._infoTxt.selectable = false;
            this._infoTxt.multiline = true;
            this._infoTxt.wordWrap = true;
            addChild(this._infoTxt);
            this._checkBox = new GCheckBox();
            this._checkBox.styleName = "GCheckBox";
            this._checkBox.label = Language.getString(54167);
            this._checkBox.width = 200;
            this._checkBox.selected = false;
            this._checkBox.addEventListener(flash.events.Event.CHANGE, this.onCheckBoxChange);
            addChild(this._checkBox);
            this._okBtn = ObjCreate.createGButton(Language.getString(54168), 60, 115, 60, 24, this);
            this._okBtn.name = "ok";
            this._cancelBtn = ObjCreate.createGButton(Language.getString(54169), 170, 115, 60, 24, this);
            this._cancelBtn.name = "cancel";
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            this._cancelBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        protected /* override */ updateSize(): void
        {
            titleHeight = 30;
            super.updateSize();
            title.y = 10;
            this._infoTxt.x = this._middleBg.x + 10;
            this._infoTxt.y = this._middleBg.y + 20;
            this._infoTxt.width = this._middleBg.width - 20;
            this._checkBox.x = this._infoTxt.x;
            this._checkBox.y = 90;
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=(arg1.target as GButton).name;
            if (loc1 != "ok") 
            {
                this._isOk = false;
            }
            else 
            {
                this._isOk = true;
            }
            if (RefreshConfirmWindow.clickHandler != null) 
            {
                RefreshConfirmWindow.clickHandler(this._isOk);
            }
            return;
        }

        public get isOk(): Boolean
        {
            return this._isOk;
        }

        /* internal */ /* var */_middleBg: ScaleBitmap;

        /* internal */ /* var */_infoTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_checkBox: GCheckBox;

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_cancelBtn: GButton;

        /* internal */ /* var */_isOk: Boolean;

        public static /* var */confirmKey: string="PetSkillRefreshConfirmKey";

        public static /* var */clickHandler: Function;
    }

            RefreshConfirmWindow.confirmKey = "PetSkillRefreshConfirmKey";
        